package com.a1anwang.okble.permission;

import ohos.security.SystemPermission;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.jar.Manifest;


/**
 * <pre>
 *     author: Blankj
 *     blog  : http://blankj.com
 *     time  : 2017/12/29
 *     desc  : The constants of permission.
 * </pre>
 */
public final class PermissionConstants {

    private static final String CALENDAR = "permission_group.CALENDAR";
    private static final String CAMERA = "permission_group.CAMERA";
    private static final String CONTACTS = "permission_group.CONTACTS";
    private static final String MICROPHONE = "permission_group.MICROPHONE";
    private static final String PHONE = "permission_group.PHONE";
    private static final String SENSORS = "permission_group.SENSORS";
    private static final String SMS = "permission_group.SMS";
    private static final String STORAGE = "permission_group.STORAGE";

    private static final String[] GROUP_CALENDAR = {
            "ohos.permission.READ_CALENDAR", "ohos.permission.WRITE_CALENDAR"
    };
    private static final String[] GROUP_CAMERA = {
            "ohos.permission.CAMERA"
    };
    private static final String[] GROUP_CONTACTS = {
            "ohos.permission.READ_CONTACTS", "ohos.permission.WRITE_CONTACTS"
    };
    private static final String[] GROUP_LOCATION = {
            "ohos.permission.LOCATION_IN_BACKGROUND", "ohos.permission.LOCATION"
    };
    private static final String[] GROUP_MICROPHONE = {
            "ohos.permission.MICROPHONE"
    };
    private static final String[] GROUP_PHONE = {
            SystemPermission.GET_TELEPHONY_STATE, SystemPermission.SET_TELEPHONY_STATE,
    };
    private static final String[] GROUP_SENSORS = {
            SystemPermission.ACCELEROMETER, SystemPermission.GYROSCOPE
    };
    private static final String[] GROUP_SMS = {
            SystemPermission.SEND_MESSAGES, SystemPermission.RECEIVE_SMS, SystemPermission.RECEIVE_WAP_MESSAGES,
            SystemPermission.READ_MESSAGES
    };
    private static final String[] GROUP_STORAGE = {
            "ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA"
    };
    /**
     * 位置权限
     *
     */
    public static final String LOCATION = "permission_group.LOCATION";
    @StringDef({CALENDAR, CAMERA, CONTACTS, LOCATION, MICROPHONE, PHONE, SENSORS, SMS, STORAGE,})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Permission {
    }
    /**
     * 获取
     *
     * @param permission 权限
     * @return string[]
     */
    public static String[] getPermissions(@Permission final String permission) {
        switch (permission) {
            case CALENDAR:
                String[] groupCalendar = GROUP_CALENDAR;
                return groupCalendar;
            case CAMERA:
                String[] groupCamera = GROUP_CAMERA;
                return groupCamera;
            case CONTACTS:
                String[] groupContacts = GROUP_CONTACTS;
                return groupContacts;
            case LOCATION:
                String[] groupLocation = GROUP_LOCATION;
                return groupLocation;
            case MICROPHONE:
                String[] groupMicrophone = GROUP_MICROPHONE;
                return groupMicrophone;
            case PHONE:
                String[] groupPhone = GROUP_PHONE;
                return groupPhone;
            case SENSORS:
                String[] groupSensors = GROUP_SENSORS;
                return groupSensors;
            case SMS:
                String[] groupSms = GROUP_SMS;
                return groupSms;
            case STORAGE:
                String[] groupStorage = GROUP_STORAGE;
                return groupStorage;
            default:
                break;
        }
        return new String[]{permission};
    }
}
